/**
   AdminsServiceImpl
 * Time:2018年5月25日
 */
package com.ssm.service.impl;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.omg.CORBA.UserException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpRequest;
import org.springframework.stereotype.Service;

import com.ssm.dao.AdminsMapper;
import com.ssm.entity.Admins;
import com.ssm.entity.AdminsExample;
import com.ssm.entity.AdminsExample.Criteria;
import com.ssm.service.AdminsService;

/**
 * @author 15199
 *
 */
@Service("adminsService")
public class AdminsServiceImpl implements AdminsService {

	/* (non-Javadoc)
	 * @see com.ssm.service.AdminsService#checkLogin(com.ssm.entity.AdminsExample)
	 */
	@Resource
	private AdminsMapper adminsMapper;
	
	@Override
	public List<Admins> checkLogin(Admins admins) {
		// TODO Auto-generated method stub
	  AdminsExample adminsExample=new AdminsExample();
	  Criteria criteria=adminsExample.createCriteria();
	  
	  if(admins.getAdmijnaccount()!=null&&admins.getAdminpassword()!=null){ 
		  criteria.andAdmijnaccountEqualTo(admins.getAdmijnaccount());
		  criteria.andAdminpasswordEqualTo(admins.getAdminpassword());
		  return adminsMapper.selectByExample(adminsExample);
	  }else{
		  return null;
	  }
		
		
		
	}

	/* (non-Javadoc)
	 * @see com.ssm.service.AdminsService#updatePassword(com.ssm.entity.Admins)
	 */
	@Override
	public int updatePassword(Admins admins) {
		// TODO Auto-generated method stub
		AdminsExample adminsExample=new AdminsExample();
		int aid;
		Criteria criteria=adminsExample.or();
		
		if(admins.getAdmijnaccount()!=null&&admins.getAdminpassword()!=null){
			
			criteria.andAdmijnaccountEqualTo(admins.getAdmijnaccount());
	         System.out.println(admins.getAdmijnaccount());
			
			List<Admins> list=adminsMapper.selectByExample(adminsExample);
			
			aid=list.get(0).getAdminid();
			
			Admins admins1=new Admins(aid,admins.getAdmijnaccount(),admins.getAdminpassword());
			
	
		    return adminsMapper.updateByPrimaryKeySelective(admins1);
		}
		
		
		
		
		
		
		
		
		return 0;
	}

}
